Currently existing devices for counting the strokes of a piston sliding within a cylinder are provided with a rod connected to the piston; the rod cooperates with a mechanical proximity sensor which senses its movements and then operates a device for counting the piston strokes.